/**
 * This software was produced for the U. S. Government
 * under Contract No. FA8721-09-C-0002, and is
 * subject to the Rights in Noncommercial Computer Software
 * and Noncommercial Computer Software Documentation Clause
 * (DFARS) 252.227-7014 (JUN 1995)
 * 
 * (c) 2009 The MITRE Corporation. All Rights Reserved.
 *
 * SPMIF to OPNET Translator
 * Author: EWALTERS
 * Created: 11:21:25 AM, Nov 30, 2007
 * MITRE Corporation
 */
package com.mitre.spmif2opnet.analysis;

/**
 * Translates S-PMIF Priorities directly into OPNET priorities
 */
public class DirectPriorities extends Priorities {

	/**
	 * Default constructor
	 * @param type Priority type
	 */
	public DirectPriorities(PriorityType type) {
		super(type);
	}
	
	/**
	 * Move S-PMIF priorities directly into OPNET priorities,
	 * saturating if the S-PMIF priority > OPNET priority, e.g.
	 * 	S-PMIF 3  -> OPNET 3
	 *  S-PMIF 10 -> OPNET 10
	 *  S-PMIF 13 -> OPNET 10
	 */
	@Override
	public void calculate() throws AnalysisException {
		for (String id : this._spmif_priorities.keySet()) {
			Integer val = this._spmif_priorities.get(id);
			if (val == null) {
				val = new Integer(-1);
			} else if (val >= _opnet_scale){
				val = (new Double(_opnet_scale)).intValue() - 1;
			}
			this._opnet_priorities.put(id, val);
		}
		this._processed = true;
	}

}
